Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
stream-executor
Advanced tools
npm i stream-executor
import { createStream, map, which, filter, tap } from 'stream-executor'
let isSucceeded = false
const chainResult = createStream(1)
.chain(
map((it) => it * 10),
which(
(it) => it > 1,
tap((it) => (isSucceeded = true)),
tap((it) => console.log('not succeeded'))
),
filter((it) => it >= 10)
)
.execute()
console.log(isSucceeded) // true
console.log(chainResult) // 10
let isSucceeded = false
const initialValue = 1
let value = 0
if (value >= 0) {
value = initialValue * 10
}
if (value > 1) {
isSucceeded = true
} else {
console.log('not succeeded')
}
if (value < 10) {
return
}
const result = value
console.log(isSucceeded) // true
console.log(result) // 10
import { createStream, ifRight, which } from 'stream-executor'
const mammal = { no: 999, name: 'UNKNOWN', type: 'bird' }
let isLoading = true
createStream(mammal)
.batch(
(_) => (isLoading = true),
which(
({ type }) => type === 'bird',
(it) => calculateSize(it),
(_) => console.log('Not Bird')
),
ifRight(
({ type, name }) => type === 'bird' && name === 'UNKNOWN',
(mammal) => registerDB(mammal)
),
(_) => (isLoading = false),
(_) => console.log('end')
)
.execute()
console.log(isLoading) // false
let isLoading: boolean
const mammal = { no: 999, name: 'UNKNOWN', type: 'bird' }
isLoading = true
if (mammal.type === 'bird') {
calculateSize(mammal)
} else {
console.log('Not Bird')
}
if (mammal.type == 'bird' && mammal.name !== 'UNKNOWN') {
console.log('maybe new species')
registerDB(mammal)
}
isLoading = false
console.log('end')
console.log(isLoading) // false
import { createStream, tap, map } from 'stream-executor'
const result = await createStream(1)
.asyncChain(
tap(async (it) => console.log(await it)), // 1
map(async (it) => await callAPI(it)),
map(async (it) => parseToModel(await it)) // Record<string, any>
)
.execute()
console.log(result) // Record<string, any>
(async () => {
let result
const value = 1
result = await callAPI(value)
result = await parseToModel(result)
console.log(result)
})()
createStream
deepCopy
method if you'd like to do deep copy, please.import { createStream, tap, deepCopy } from 'stream-executor'
const input = { value: 1 }
const result = createStream(input)
.chain(tap((it) => (it.value += 9)))
.execute()
console.log(input) // { value: 10 }
console.log(result) // { value: 10 }
const input2 = { value: 1 }
const result2 = createStream(deepCopy(input2))
.chain(tap((it) => (it.value += 9)))
.execute()
console.log(input2) // { value: 1 }
console.log(result2) // { value: 10 }
deepCopy
import { createStream, tap, deepCopy } from 'stream-executor'
class Wrapper<T> {
value: T
constructor(value: T) {
this.value = value
}
get doubledValue() {
return this.value * 2
}
hello() {
console.log('world')
}
}
const input = new Wrapper(1)
const result = createStream(deepCopy(input))
.chain(tap((it) => (it.value += 9)))
.execute()
console.log(input) // Wrapper{ value: 1, doubledValue: 2, __proto__: { hello: () => console.log('world') } }
console.log(result) // { value: 10, __proto__: {} }
createStream().chain()
:undefined
returnedimport { createStream, tap, filter, map } from 'stream-executor'
const result = createStream(1)
.chain(
tap((it) => console.log(it)), // 1
filter((it) => it > 2), // return undefined
map((it) => it + 9) // not called
)
.execute()
console.log(result) // undefined
let error: any
createStream(1)
.batch(
(it) => console.log(it),
..
)
.execute((err: any) => {
console.error(error)
error = err
})
chain
or batch
executoroption.chainClass
or option.batchClass
if you would change execution process, pleaseimport { BaseExecutor, createStream } from 'stream-executor'
class MockChainExecutor implements BaseExecutor {
constructor(public initialValue: any) {}
stream(...args: any[]) {
return this
}
execute() {
console.log('MockChainExecutor called')
}
}
class MockBatchExecutor implements BaseExecutor {
constructor(public initialValue: any) {}
stream(...args: any[]) {
return this
}
execute() {
console.log('MockBatchExecutor called')
}
}
createStream(1, { chainClass: MockChainExecutor })
.chain((it) => it)
.execute() // 'MockChainExecutor called'
createStream(1, { batchClass: MockBatchExecutor })
.batch((it) => it)
.execute() // 'MockBatchExecutor called'
FAQs
functional stream programming
The npm package stream-executor receives a total of 2 weekly downloads. As such, stream-executor popularity was classified as not popular.
We found that stream-executor demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.